﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

/**
 * 泛型委托
 */
namespace BiliBiliCSharpStudy.ch30.d09 {
    class GenericAndDelegate1 {
        public static void Demo() {
            Test2();
        }
        public static void Test2() {
            Func<int, int, int> func1 = Add;
            var result = func1(100, 200);
            Console.WriteLine(result);
            Func<double, double, double> func2 = Add;
            Console.WriteLine(func2(1.2, 2.6));
        }
        public static void Test1() {
            // Action 只能委托“无返回值”的函数
            Action<string> a1 = Say;
            a1.Invoke("Timothy");
            a1("Timothy");
            Action<int> a2 = Mul;
            a2(2);
        }
        static void Say(string str) {
            Console.WriteLine($"Hello, {str}!");
        }
        static void Mul(int x) {
            Console.WriteLine(x * 100);
        }

        static int Add(int a, int b) {
            return a + b;
        }
        static double Add(double a, double b) {
            return a + b;
        }
    }

}
